package com.rftennis.web.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.rftennis.dto.JSONResponce;

import com.rftennis.dto.QueryResult;
import com.rftennis.entity.OrderEntity;
import com.rftennis.service.OrderService;
import com.rftennis.vo.OrderVo;

@Controller
public class OrderController {
	@Autowired
	OrderService service;
	
	
	@GetMapping("/order/selectkey.do")
	public @ResponseBody JSONResponce selectIdKeyOrder(String customerId,String key, String pageNo, String pageSize) throws Exception {
	

		int pageNoInt =Integer.parseInt(pageNo);
		int pageSizeInt =Integer.parseInt(pageSize);
		// 2调用业务方法

		
		QueryResult<OrderEntity> queryResult = service.selectIdKeyOrder(customerId, key, pageNoInt, pageSizeInt);
		QueryResult<OrderVo> queryVoResult=queryResult.rowsMap(OrderVo::of);
		return JSONResponce.ok(queryVoResult);

	}
	@GetMapping("/order/selectAllkey.do")
	public @ResponseBody JSONResponce selectKeyOrder(String key, String pageNo, String pageSize) throws Exception {
	

		int pageNoInt =Integer.parseInt(pageNo);
		int pageSizeInt =Integer.parseInt(pageSize);
		// 2调用业务方法
        QueryResult<OrderEntity> queryResult = service.selectKeyOrder(key, pageNoInt, pageSizeInt);
        System.out.println("我是dto");
		for(int i = 0 ; i <queryResult.getRows().size(); i++) {
			  System.out.println(queryResult.getRows().get(i));
			}
		QueryResult<OrderVo> queryVoResult=queryResult.rowsMap(OrderVo::of);
		System.out.println("我是vo");
		for(int i = 0 ; i <queryVoResult.getRows().size(); i++) {
			  System.out.println(queryVoResult.getRows().get(i));
			}
		return JSONResponce.ok(queryVoResult);

	}
}
